Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ssr): properly init slots during ssr rendering #12441

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

edison1105
Copy link
Member

@edison1105 edison1105 commented Nov 20, 2024

close #12438

during SSR rendering, the optimized parameter passed to initSlots is always false. The slots._ flag is lost when initSlots is called in setupComponent for the child component. This triggers the logic inside normalizeObjectSlots, resulting in slotFn returning an array that includes a comment node.

const ret = slotFn(
slotProps,
bufferedPush,
parentComponent,
slotScopeId ? ' ' + slotScopeId : '',
)
if (isArray(ret)) {

related commit 3d34f40#diff-56930a63772d2e89f19432918b9d6ed851ede4159b0d32404e0c1d8c159fec99R1232
SSR rendering does not need to patch slots, so there won't be an issue similar to #10870. Perhaps the optimized parameter can always be set to true.

Copy link

github-actions bot commented Nov 20, 2024

Size Report

Bundles

File Size Gzip Brotli
runtime-dom.global.prod.js 100 kB (+3 B) 37.9 kB (-1 B) 34.2 kB (-2 B)
vue.global.prod.js 158 kB (+3 B) 57.8 kB (+3 B) 51.5 kB (+99 B)

Usages

Name Size Gzip Brotli
createApp (CAPI only) 47.2 kB (+3 B) 18.3 kB (+2 B) 16.8 kB (-3 B)
createApp 55.2 kB (+3 B) 21.3 kB (+2 B) 19.5 kB (-6 B)
createSSRApp 59.3 kB (+3 B) 23.1 kB (+4 B) 21 kB (+1 B)
defineCustomElement 60.1 kB (+3 B) 22.9 kB (+3 B) 20.9 kB (+3 B)
overall 69.1 kB (+3 B) 26.5 kB (+2 B) 24.1 kB (+15 B)

Copy link

pkg-pr-new bot commented Nov 20, 2024

Open in Stackblitz

@vue/compiler-core

pnpm add https://pkg.pr.new/@vue/compiler-core@12441

@vue/compiler-dom

pnpm add https://pkg.pr.new/@vue/compiler-dom@12441

@vue/compiler-ssr

pnpm add https://pkg.pr.new/@vue/compiler-ssr@12441

@vue/compiler-sfc

pnpm add https://pkg.pr.new/@vue/compiler-sfc@12441

@vue/reactivity

pnpm add https://pkg.pr.new/@vue/reactivity@12441

@vue/runtime-core

pnpm add https://pkg.pr.new/@vue/runtime-core@12441

@vue/runtime-dom

pnpm add https://pkg.pr.new/@vue/runtime-dom@12441

@vue/server-renderer

pnpm add https://pkg.pr.new/@vue/server-renderer@12441

@vue/shared

pnpm add https://pkg.pr.new/@vue/shared@12441

vue

pnpm add https://pkg.pr.new/vue@12441

@vue/compat

pnpm add https://pkg.pr.new/@vue/compat@12441

commit: 413c923

@edison1105 edison1105 requested a review from Copilot November 20, 2024 02:21

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 2 out of 2 changed files in this pull request and generated no suggestions.

@edison1105 edison1105 added ready to merge The PR is ready to be merged. scope: ssr 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. labels Nov 20, 2024
@edison1105 edison1105 changed the title fix(ssr): properly handle ssr slot and fallback fix(ssr): properly init slots during ssr rendering Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. ready to merge The PR is ready to be merged. scope: ssr
Projects
None yet
Development

Successfully merging this pull request may close these issues.

slot with always-true condition is not rendered on ssr
1 participant